package com.ruoyi.basicData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basicData.domain.StorManagement;
import com.ruoyi.basicData.service.IStorManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库位管理Controller
 * 
 * @author admin
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/basicData/storManagement")
public class StorManagementController extends BaseController
{
    @Autowired
    private IStorManagementService storManagementService;


    /**
     * 查询库位管理列表
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorManagement storManagement)
    {
        startPage();
        List<StorManagement> list = storManagementService.selectStorManagementList(storManagement);
        return getDataTable(list);
    }

    /**
     * 导出库位管理列表
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:export')")
    @Log(title = "库位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StorManagement storManagement)
    {
        List<StorManagement> list = storManagementService.selectStorManagementList(storManagement);
        ExcelUtil<StorManagement> util = new ExcelUtil<StorManagement>(StorManagement.class);
        util.exportExcel(response, list, "库位管理数据");
    }

    /**
     * 获取库位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:query')")
    @GetMapping(value = "/{storManagementId}")
    public AjaxResult getInfo(@PathVariable("storManagementId") Long storManagementId)
    {
        return success(storManagementService.selectStorManagementByStorManagementId(storManagementId));
    }

    /**
     * 新增库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:add')")
    @Log(title = "库位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorManagement storManagement)
    {
        return toAjax(storManagementService.insertStorManagement(storManagement));
    }

    /**
     * 修改库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:edit')")
    @Log(title = "库位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorManagement storManagement)
    {
        return toAjax(storManagementService.updateStorManagement(storManagement));
    }

    /**
     * 删除库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:storManagement:remove')")
    @Log(title = "库位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{storManagementIds}")
    public AjaxResult remove(@PathVariable Long[] storManagementIds)
    {
        return toAjax(storManagementService.deleteStorManagementByStorManagementIds(storManagementIds));
    }
}
